<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Exceptions\InvalidRequestException;
use Illuminate\Contracts\validation\Validator;

class CommonRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    protected function failedValidation(Validator $validator) 
    {
        throw new InvalidRequestException($validator->errors()->first());
    }

    public function scene() {
        $scene = explode('/', request()->pathInfo);
        return end($scene);
    }

}
